package 矩阵中的蛇3248;

import java.util.List;
import java.util.Objects;

public class Solution {
    public int finalPositionOfSnake(int n, List<String> commands) {
        int[][] arr = new int[n][n];
        int i = 0, j = 0;
        for (String s : commands) {
            if(Objects.equals(s, "UP")) {
                i--;
            }
            if(Objects.equals(s, "DOWN")) {
                i++;
            }
            if(Objects.equals(s, "LEFT")) {
                j--;
            }
            if(Objects.equals(s, "RIGHT")) {
                j++;
            }
        }
        return i * n + j;
    }
}
